package com.kingyea.mobilepolice.apimanage.config;

import com.kingyea.mobilepolice.apimanage.test.service.HelloWorldImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

// TODO: 2018/10/6 跟kingyea 的 cxf模块jar冲突, 暂时停用,测试方法移到另外的工程
@Configuration
public class WebServiceConfig {
    @Autowired
    private Bus bus;

    /**
     * Spring Boot CXF JAX-WS Starter 需要接口和实现类写@WebService注解
     **/
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, new HelloWorldImpl());

//        SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
//        binding.setMTOMEnabled(true);

        endpoint.publish("/Hello");
        return endpoint;
    }


    /** Spring Boot CXF JAX-RS Starter 直接在接口注解即可发布接口 **/
//    @Bean
//    public Server rsServer() {
//        JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
//        endpoint.setBus(bus);
//        endpoint.setAddress("/");
//        // Register 2 JAX-RS root resources supporting "/sayHello/{id}" and "/sayHello2/{id}" relative paths
//        endpoint.setServiceBeans(Arrays.<Object>asList(new HelloWorldImpl()));
//        endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
//        return endpoint.create();
//    }
}